package com.ymatou.operate.trading.api.service;

import org.json.JSONException;
import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

/**
 * 退货退款申请效验接口Call FreeMaker Template自动生成代码
 */
public class ApplyValidationCall extends YmatouBaseCall {
    private static String opurl = "api/SalesRefund/ApplyValidation";

    public ApplyValidationCall() {
        super(EnvSetup.getSystemUrl("api_order_operate"), opurl, "POST", "JSON");
    }

    @Override
    public void addDefHeader() {
        client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
        client.addHeader("Content-Type", "application/json; charset=UTF-8");
    }

    //
    public JSONObject getData() {
        JSONObject data = null;
        try {
            data = new JSONObject(getReturnData()).getJSONObject("Data");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return data;
    }

    // OrderOperationInfo 下type值
    public int getOperateType() {
        int type = 0;
        try {
            type = getData().getJSONObject("OrderOperationInfo").getInt("Type");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return type;
    }
}
